﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tesla.Service.WcfServiceCommon;
using Tesla.Business.BusinessLogic;
using Tesla.Service.DataContracts;
using Tesla.Util.Utilities;
using System.ServiceModel;
using System.Data.SqlClient;
using Tesla.Service.ServiceContracts;
using Tesla.Business.BusinessLogic.Implementations;
using Tesla.Business.BusinessLogic.Interfaces;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace Tesla.Service.ServiceImplementations
{
    public class SvcTimeSheet:ISvcTimeSheet
    {
        public IList<BaseDC> ReadTasksForTimeSheet(int ProjectID, int FinYr, int EmpID)
        {
            IList<BaseDC> baseDCs = null;
            try
            {
                using (ContextBL cBL = new ContextBL())
                {
                    ITimeSheetBL iblTS = cBL.CreateSpecializedBL(EntityMapper.TIMESHEETBL) as ITimeSheetBL;
                    baseDCs = iblTS.ReadTasksForTimeSheet(ProjectID,FinYr,EmpID);
                }
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, "GADN Custom Exception Policy");
                if (rethrow)
                    throw;
            }
            return baseDCs;
        }

        public IList<BaseDC> ReadWeeksCalendar(int ProjectID, int FinYr, DateTime refdate)
        {
            IList<BaseDC> baseDCs = null;
            try
            {
                using (ContextBL cBL = new ContextBL())
                {
                    ITimeSheetBL iblTS = cBL.CreateSpecializedBL(EntityMapper.TIMESHEETBL) as ITimeSheetBL;
                    baseDCs = iblTS.ReadWeeksCalendar(ProjectID, FinYr, refdate);
                }
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, "GADN Custom Exception Policy");
                if (rethrow)
                    throw;
            }
            return baseDCs;
        }
    }
}
